<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of mpower</title>
  <meta name="keywords" content="mpower">
  <meta name="description" content="p^t is p multiplied by itself t times. May have t <= 0.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="../index.html">matgraph</a> &gt; <a href="index.html">@permutation</a> &gt; mpower.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for matgraph/@permutation&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>mpower
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>p^t is p multiplied by itself t times. May have t <= 0.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function q = mpower(p,t) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> p^t is p multiplied by itself t times. May have t &lt;= 0.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="inv.html" class="code" title="function q = inv(p)">inv</a>	inv(p) returns the inverse permutation of p</li><li><a href="length.html" class="code" title="function s = length(p)">length</a>	length(p) gives the size of the permutation</li><li><a href="permutation.html" class="code" title="function p = permutation(n)">permutation</a>	constructor for the permutation class</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function q = mpower(p,t)</a>
0002 <span class="comment">% p^t is p multiplied by itself t times. May have t &lt;= 0.</span>
0003 <span class="keyword">if</span> t==0
0004     q = <a href="permutation.html" class="code" title="function p = permutation(n)">permutation</a>(<a href="length.html" class="code" title="function s = length(p)">length</a>(p));
0005     <span class="keyword">return</span>
0006 <span class="keyword">end</span>
0007 
0008 <span class="keyword">if</span> t&lt;0
0009     q = (<a href="inv.html" class="code" title="function q = inv(p)">inv</a>(p))^(-t);
0010     <span class="keyword">return</span>
0011 <span class="keyword">end</span>
0012 
0013 <span class="keyword">if</span> t == 1
0014     q = p;
0015     <span class="keyword">return</span>
0016 <span class="keyword">end</span>
0017 
0018 <span class="comment">% recurse when t&gt;1</span>
0019 
0020 <span class="keyword">if</span> mod(t,2) == 0
0021     q = p^(t/2);
0022     q = q*q;
0023 <span class="keyword">else</span>
0024     q = p^((t-1)/2);
0025     q = p*q*q;
0026 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Fri 30-Apr-2010 07:51:16 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>